package com.qfedu.service.impl;

import com.qfedu.dao.ProductDao;
import com.qfedu.dao.impl.ProductDaoImpl;
import com.qfedu.model.Product;
import com.qfedu.service.ProductService;

import java.util.List;


public class ProductServiceImpl implements ProductService {
    private ProductDao productDao = new ProductDaoImpl();
    @Override
    public List<Product> findAll() {
        //查询的结果
        List<Product> all = productDao.findAll();

        return all;
    }

    @Override
    public Product findProByPid(int id) {
        return productDao.findProByPid(id);
    }

    @Override
    public int addProduct(Product product) {
        return productDao.addProduct(product);
    }

    @Override
    public int updatePro(Product product) {
        return productDao.updatePro(product);
    }

    @Override
    public int deleteProduct(int id) {
        return productDao.deleteProduct(id);
    }

    @Override
    public void deleteBatch(List<Integer> list) {
        //持久层执行单一的删除动作
        if (list != null && list.size()>0 ){
            //批量操作必须加上事务管理
            for (Integer integer :list){
                productDao.deleteProduct(integer);
            }
        }
    }
}